package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.AppsflyerChannel;
import com.ruoyi.bizsys.service.IAppsflyerChannelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * appsflyerChannelController
 *
 * @author ygw
 * @date 2022-08-12
 */
@RestController
@RequestMapping("/bizsys/channel")
public class AppsflyerChannelController extends BaseController {
    @Autowired
    private IAppsflyerChannelService appsflyerChannelService;

    /**
     * 查询appsflyerChannel列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:channel:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppsflyerChannel appsflyerChannel) {
        startPage();
        List<AppsflyerChannel> list = appsflyerChannelService.selectAppsflyerChannelList(appsflyerChannel);
        return getDataTable(list);
    }

    /**
     * 导出appsflyerChannel列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:channel:export')")
    @Log(title = "appsflyerChannel", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppsflyerChannel appsflyerChannel) {
        List<AppsflyerChannel> list = appsflyerChannelService.selectAppsflyerChannelList(appsflyerChannel);
        ExcelUtil<AppsflyerChannel> util = new ExcelUtil<AppsflyerChannel>(AppsflyerChannel.class);
        return util.exportExcel(list, "channel");
    }

    /**
     * 获取appsflyerChannel详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:channel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(appsflyerChannelService.selectAppsflyerChannelById(id));
    }

    /**
     * 新增appsflyerChannel
     */
    @PreAuthorize("@ss.hasPermi('bizsys:channel:add')")
    @Log(title = "appsflyerChannel", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppsflyerChannel appsflyerChannel) {
        return toAjax(appsflyerChannelService.insertAppsflyerChannel(appsflyerChannel));
    }

    /**
     * 修改appsflyerChannel
     */
    @PreAuthorize("@ss.hasPermi('bizsys:channel:edit')")
    @Log(title = "appsflyerChannel", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppsflyerChannel appsflyerChannel) {
        return toAjax(appsflyerChannelService.updateAppsflyerChannel(appsflyerChannel));
    }

    /**
     * 删除appsflyerChannel
     */
    @PreAuthorize("@ss.hasPermi('bizsys:channel:remove')")
    @Log(title = "appsflyerChannel", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(appsflyerChannelService.deleteAppsflyerChannelByIds(ids));
    }
}
